#pragma once

#include <d3dx9.h>
#include <windows.h>

//************************************************************************************************//
//******                                                                                    ******//
//******	DXSniffer	- The class that handles information extraction from DX calls		******//
//******                                                                                    ******//
//************************************************************************************************//
class DXSniffer
{
public:
	//	Singleton Instance retriver
	static DXSniffer* Instance()
	{
		static DXSniffer infoSniffer;
		return &infoSniffer;
	}

	//--------------------------------------------------------------------------------------------
	//
	//			DXFunctions interceptors
	//
	//--------------------------------------------------------------------------------------------
	void DrawPrimitiveUsed(	IDirect3DDevice9* p_this_pointer, D3DPRIMITIVETYPE p_enumPrimitiveType, 
		UINT p_uintStartVertex,UINT p_uintPrimitiveCount);
	void DrawSubsetUsed(ID3DXMesh* p_this_pointer, DWORD p_dAttribs);
	void PresentUsed (	IDirect3DDevice9* p_this_pointer, CONST RECT* p_pSourceRect,
		CONST RECT* p_pDestRect, HWND p_hDestWindowOverride, CONST RGNDATA* p_pDirtyRegion);

	//----------------------------------------------------
	//
	//				Sniffer control options
	//
	//----------------------------------------------------
	//	Should Log to console (from Present till Present)
	bool m_bPrintToConsole;
	
	//	Draw the backbuffer to a new window
	void CreateAlternativeView();

private:

	//	Private C'tor and D'tor - Singleton
	DXSniffer(void);
	~DXSniffer(void);

	static LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );

	bool m_bLogCycle;
	bool m_bAlternativeView;

	WNDCLASSEX m_wcAlternativeWC;
	HWND m_hAlternativeHWnd;

	struct VERTEX;
};
